<template>
  <Dialog
    v-model="curValue"
    :search-fun="searchFun"
    title="办事处"
    value-key="label"
    interface-path="/api/v1/organization/agencies"
    :setting="setting"
    v-bind="$attrs"
    @select="selectHandle"
    @selection-change="selectionChange"
  />
</template>
<script>
import Dialog from './Dialog'
export default {
  name: 'CAgency',
  components: {
    Dialog
  },
  props: {
    value: {
      type: [String, Array],
      default: ''
    }
  },
  data() {
    return {
      curValue: '',
      selection: undefined,
      setting: [
        {
          prop: 'dictCode',
          label: '字典码'
        },
        {
          prop: 'dictName',
          label: '字典名'
        }
      ]
    }
  },
  watch: {
    value: {
      handler(n) {
        this.curValue = n
      },
      immediate: true
    },
    curValue(n) {
      this.$emit('input', n)
    }
  },
  methods: {
    searchFun(value, cb) {
      // 获取部门信息
      cb([
        { value: '1', label: '测试1' },
        { value: '2', label: '测试2' }
      ])
    },
    selectHandle(v) {
      this.selection = v
    },
    selectionChange(v) {
      this.selection = v
    }
  }
}
</script>
<style lang="scss" scoped>
.agency {
  width: 100%;
}
</style>
